package ch.rgw.cybert;

import java.util.Arrays;
import java.util.List;

import ch.rgw.cybert.Cybert;

import org.junit.Test;

public class Test_Cybert {
	final String macbook_unplugged = "192.168.56.101";
	final String macbook_plugged = "192.168.1.6";
	final String lan = "192.168.0.21";
	final String couchone = "elexis.couchone.com";

	@SuppressWarnings("unchecked")
	@Test
	public void testIt() throws Exception {
		Cybert.setup("localhost", "knols2");
		List<String> initial = (List<String>) Cybert.getInitialQuestions(5);
		if (initial.size() < 5) {
			for (int i = 0; i < initialTheses.length; i++) {
				Cybert.addProposal(initialTheses[i][0], initialTheses[i][1],
						Integer.parseInt(initialTheses[i][3]), "TestSuite",
						Integer.parseInt(initialTheses[i][2]), Float
								.parseFloat(initialTheses[i][4]), Float
								.parseFloat(initialTheses[i][5]));
			}
			Cybert.flush();
			initial = (List<String>) Cybert.getInitialQuestions(5);
		}
		for (String s : initial) {
			System.out.println(s);
		}
		// we go for Appendicitis in this test
		Integer[] answers = new Integer[] { -4, -3, 4, -4, 4 };
		List<String> proposals = (List<String>) Cybert.getProposals();
		for (String s : proposals) {
			System.out.println(s);
		}
		String question = (String) Cybert.getFirstQuestion(Arrays
				.asList(answers));
		System.out.println(question);
		question = (String) Cybert.getNextQuestion(4);
		System.out.println(question);
		proposals = (List<String>) Cybert.getProposals();
		for (String s : proposals) {
			System.out.println(s);
		}
		Cybert.addQuestion("Leucocytosis?", 4, "TestSuite", 2, 1f,1.5f);
		Cybert.applyHypothesis("Appendicitis", "TestSuite");
	}

	private String[][] initialTheses = {
			{ "grippaler Infekt", "Fieber", "1", "3", "1", "1" },
			{ "Angina", "Halsweh", "0", "4", "1.5", "2" },
			{ "Myokardinfarkt", "Thoraxschmerz", "0", "4", "1", "1.5" },
			{ "Asthma", "Dyspnoe", "0", "4", "1", "1.5" },
			{ "Appendicitis", "Bauchschmerzen", "0", "4", "1", "2" },
			{ "Appendicitis", "Fieber", "1", "3", "1", "2" },
			{ "Appendicitis", "Thoraxschmerz", "0", "-4", "1", "1" },
			{ "Appendicitis", "Halsweh", "0", "-4", "1", "1" },
			{ "Myokardinfarkt", "Fieber", "1", "0", "1", "1" },
			{ "Myokardinfarkt", "Dyspnoe", "0", "2", "1", "1" },
			{ "Appendicitis", "Défense", "2", "4", "1.5", "1.5" },
			{ "grippaler Infekt", "Thoraxschmerz", "0", "1", "1", "1" },
			{ "grippaler Infekt", "Défense", "2", "-3", "1", "1" },
			{ "Angina", "Bauchschmerzen", "0", "-4", "1", "1" } };

}
